package com.sun.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter("/*")
public class ChharacterFilter implements Filter {
	/**
	 * 字符编码过滤
	 * @param servletRequest
	 * @param servletResponse
	 * @param filterChain
	 * @throws IOException
	 * @throws ServletException
	 */
	@Override
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
		servletRequest.setCharacterEncoding("utf8");
		servletResponse.setCharacterEncoding("utf8");
		filterChain.doFilter(servletRequest, servletResponse);
	}
}
